package com.dwxt.community.admin.controller;

import com.dwxt.common.base.BaseResult;
import com.dwxt.community.admin.service.EditContentService;
import com.dwxt.community.entity.EditContent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/cms/editcontent")
public class EditContentControllerAdmin {

    @Autowired
    private EditContentService editContentService;

    @RequestMapping("/selectList")
    public BaseResult selectList(@RequestParam(defaultValue = "1") Integer pageNum,
                                 @RequestParam(defaultValue = "10") Integer pageSize){
        return editContentService.selectList(pageSize,pageNum);
    }

    /**
     * @param editContent
     *     private Integer id;
     *     private String editName;
     *     private String editContent;
     * @return
     */
    @RequestMapping("/insertOrUpdate")
    public BaseResult insertOrUpdate(EditContent editContent){
        editContentService.insertOrUpdate(editContent);
        return BaseResult.ok();
    }

    @RequestMapping("/delete")
    public BaseResult delete(@RequestParam(required = true)Integer id){
        editContentService.delete(id);
        return BaseResult.ok();
    }
}
